<template>
	<view class="conter">
		<!-- <header-box :title="title"></header-box> -->
		<view class="header" style="color: #000000;" @tap="goBack(id)">
			<view class="arrow">
			</view>
			<view class="title">
				{{title}}
			</view>
		</view>
		
		<view class="text-tab">
			<view class="box">
				<block v-if="textAdd == 11">
					<view class="marige-bor" v-for="(item, index) in textList" :key="index"
						 @tap="skip(item)">
						<view class="diso-flex">
							<view class="">
								{{item.supplier_name}}
							</view>
						</view>
					</view>
				</block>
				<block v-else>
					<view class="marige-bor" v-for="(item, index) in textList" :key="index"
						 @tap="skip(item)">
						<view class="diso-flex">
							<view class="">
								{{item.name}}
							</view>
						</view>
					</view>
				</block>
			</view>
		</view>
		
		
		<!-- <navigator url="/pages/contact/individual" class="add">
			<image src="../../static/index/add.png" mode=""></image>
		</navigator> -->

	

		<view class="flex-box total">
			<view class="">
				合计：
			</view>
			<view class="">
				{{textList.length}} 个
			</view>
		</view>

	</view>
</template>

<script>
	import headerBox from '../../components/header/header.vue'

	export default {
		components: {
			headerBox
		},
		data() {
			return {
				title: '',
				textList: [],
				addUrl: '',
				total: 0,
				value: '',
				page: 1,
				textAdd: '',
			}
		},
		onLoad(e) {
			console.log('e==>', e.addId);
			this.textAdd = e.addId
			this.stockList()
			// 入库  供货商
			if (this.textAdd == 11) {
				this.title = '供货商'
			
			// 出库 客户
			} else {
				this.title = '客户'
			}
		},
		onShow() {},
		onReachBottom() {
			if (this.total < 15) return
			this.page++
			this.stockList()
		},
		methods: {
			
			goBack(name) {
				uni.navigateBack({
					delta: 1
				})
				
				let pages = getCurrentPages(); //获取所有页面栈实例列表
				let nowPage = pages[pages.length - 1]; //当前页页面实例
				let prevPage = pages[pages.length - 2]; //上一页页面实例
				prevPage.$vm.searchVal = this.name; //修改上一页data里面的searchVal参数值为1211
				prevPage.$vm.danweiID = this.danweiID;
			
			},
			
			// async stockList() {
			// 	const res = await this.$u.post("api/Invoic/supplier_find",{
			// 		page: this.page,
			// 		pagesize: 15,
			// 	});
			// 	this.textList = res.data
			// 	this.total = res.data.length
			// 	this.danweiID = res.data[0].id
			// 	console.log(res, 'this.value')
			// },
			
			async stockList() {
				// 入库  供货商
				if (this.textAdd == 11) {
					const res = await this.$u.post("api/Invoic/supplier_find",{
						page: this.page,
						pagesize: 20,
					});
					this.textList = res.data
					console.log(res,  '444444444')
				} else {
					const res = await this.$u.post("api/Invoic/wldw_find",{
						page: this.page,
						pagesize: 20,
					});
					this.textList = res.data
					this.total = this.textList.length
				}
			
			},
			
			skip(item) {
				console.log('item==>', item);
				this.name = item
				this.danweiID = item.id
				uni.navigateBack({
					delta: 1
				})
				let pages = getCurrentPages(); //获取所有页面栈实例列表
				let nowPage = pages[pages.length - 1]; //当前页页面实例
				let prevPage = pages[pages.length - 2]; //上一页页面实例
				prevPage.$vm.searchVal = this.name; //修改上一页data里面的searchVal参数值为1211
				prevPage.$vm.danweiID = this.danweiID;
				
			},
			
		}
	}
</script>

<style lang="scss" scoped>
	.conter {
		width: 100%;
		height: 100vh;
		position: relative;
		background-color: #EEEEEE;
		
		
		.header {
			width: 100%;
			height: 150rpx;
			line-height: 150rpx;
			display: flex;
			align-items: center;
			// padding-left: 10rpx;
			padding-top: 30rpx;
			font-size: 36rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
			background: linear-gradient(to right, #656CE6, #9397FC);
			
			.arrow{
			  position: relative;
			  display: inline-block;
			}
			
			.arrow::before{
			  content: '';
			  width: 10px;
			  height: 10px;
			  border: 0px;
			  border-bottom: solid 2px #fff;
			  border-left: solid 2px #fff;
			  -ms-transform: rotate(45deg);
			  -webkit-transform: rotate(45deg);
			  transform: rotate(45deg);
			  position: absolute;
			  top: 50%;
			  left: 0;
			  margin-top: -4px;
			  margin-left: 28rpx;
			}
			
			.title {
				color: #fff;
				margin: 0 auto;
			}
		}
		
		
		// 加号
		.add {
			position: fixed;
			bottom: 200rpx;
			right: 40rpx;
			width: 100rpx;
			height: 100rpx;
			text-align: center;
			line-height: 100rpx;
			border-radius: 50%;
			font-size: 100rpx;
		}
		
		

		image {
			width: 100%;
			height: 100%;
		}

		.text-tab {
			width: 100%;
			padding: 30rpx;
			padding-bottom: 0;


			.box {
				width: 98%;
				margin: 0 auto;
				background-color: #FFFFFF;
				border-radius: 10rpx;
			}

			.marige-bor {
				width: 90%;
				margin: 0 auto;
				color: #333333;
				display: flex;
				font-size: 28rpx;
				align-items: center;
				border-bottom: 1rpx solid #F0F0F0;
				justify-content: space-between;

				.diso-flex {
					width: 100%;
					height: 80rpx;
					display: flex;
					align-items: center;
					justify-content: space-between;
				}

				.conter-image {
					width: 22rpx;
					height: 36rpx;
				}
			}
			
			.marige-bor:last-child {
				border-bottom: 0;
			}
		}


		.total {
			width: 100%;
			position: fixed;
			bottom: 0;
			left: 0;
			height: 100rpx;
			padding: 0 60rpx 0 30rpx;
			background-color: #FFFFFF;
		}

	}
</style>
